(function(app){
	app
		.controller("content_40_checkCtrl",["$scope","myFactory",'$http','$stateParams','$state',"$q",'$timeout','$location','$ionicHistory',function($scope,myFactory,$http,$stateParams,$state,$q,$timeout,$location,$ionicHistory){
			//接收参数
			var chdrnum01 =  $stateParams.chdrnum01; //保单号
			var chdrcoy = $stateParams.chdrcoy; //保单公司号码
			var state = $stateParams.state;//获得跳转过来的路由
			var policyData;//保单详情

			//绑定到页面
			$scope.chdrnum01 = $stateParams.chdrnum01;
			$scope.showFlag = true; //控制前端是否显示“详情、重审、退出”三个功能，默认显示
			$scope.item40 = $stateParams.item40;
			$scope.FlagFor40Check =false;//控制是否显示其他生存给付方式消息
			
			/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 start*/
			$scope.peoRelationFlag = false;
			if ("" != $stateParams.item40.changeRelation && null != $stateParams.item40.changeRelation) {
				$scope.peoRelationFlag = true;
			}
			/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 end*/
			
			var value = $scope.item40.beneList[0].zdivOpt;
			if(value == 'CSWD'){//现金领取时，显示其他需要填写的信息
				$scope.FlagFor40Check = true;
			}else if(value == 'DVAC'){//储存生息/留存公司时候，隐藏其他需要填写的信息
				$scope.FlagFor40Check = false;
			}
			
			
			//重新受理
			$scope.renew = function(){
				myFactory.renew();
			}
			//退出移动保全
			$scope.exit = function(){
				myFactory.exit();
			}
			//返回函数
			$scope.goBack = function () {
				myFactory.goBack();
			}
			//生存领取方式弹框
			$scope.beneDetailModalFor40Check = function(index){
				$("#survival_receive_result_dialog").fadeToggle(50);
				
				//能点详情弹框触发这个函数说明已经有数据，不需要对数据进行判断，这里为具体读出数组第index个
				$scope.beneDetailFor40Check = $scope.item40.beneList[index];

				$("#survival_receive_result_dialog .myDialog_content .btn_close").click(function(){
					$(this).parents('#survival_receive_result_dialog').fadeOut(50);
				});
				
				$("#survival_receive_result_dialog .myDialog_black").click(function(){
					$(this).parent('#survival_receive_result_dialog').fadeOut(50);
					//$.toast("信函接收方式没有改变不需要改变", "text");
				});
			}
			
			//保单详情弹窗
			$scope.showPolicyDetail = function(){
				modal('open','policyModalOn40Check','overwindowOn40Check','policyCloseXOn40Check');
				var token=sessionStorage.getItem("token");
				var timestamp=myFactory.getTimetamp();
				var sfis= "chdrnum-chdrcoy-token-timestamp";
				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				//查询保单详情
				$http({
					method: 'GET',
					url: app.domain + 'query/restFindPolicyDetail.action',
					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						policyData = response.data.data;
						$scope.policyData = policyData;
						$scope.policyData.ptdate01=myFactory.DateTools($scope.policyData.ptdate01);
					}
				}, function errorCallback(response) {
					myFactory.alert("","初始化查询订单详情失败!","info");
				});
			}
			
			//保单详情弹窗关闭函数
			$scope.policyCancelOn40Check = function(){
				modal('close','policyModalOn40Check','overwindowOn40Check','policyCloseXOn40Check');
			}
			//关闭遮罩
			$scope.overwindowClose = function(){
				//$(".overwindow").show();
				$(".overwindow").hide();
				$(".overmodal").hide();
			}
			
			//根据路由判断是否要显示详情、重新受理、退出三个功能
			if("history_detail"==state){
				$scope.showFlag = false;//不显示
			}
			
		}]); 
	
		//指针弹窗
		app.directive('infoid',function(){
			return {
				restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
				templateUrl: 'html/input/content_base_info.html'+app.clearCache,
				replace: true,		//设置解析后，DOM声明的指令是否消失
				link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
					console.log('指令完成');
				}
			}
		});
})(app)